package misc

import (
	"strings"

	"engine/log"
	"gitee.com/ameise84/e3utils/uuid"
	"servers/models/define"
	"servers/models/error_code"
)

func IsErrorCode(code define.ErrorCode) bool {
	if code == error_code.ErrorCodeNoError {
		return false
	}
	log.GetLogger().ErrorPrintf("error code[%d]%s", code, error_code.ErrorCodeMap[code])
	return true
}

func RandString(n int) string {
	sb := strings.Builder{}
	for {
		s := uuid.NewShortV4()
		if len(s) < n {
			sb.WriteString(s)
			n -= len(s)
		} else {
			sb.WriteString(s[:n])
			break
		}
	}
	return sb.String()
}
